package com.qzsoft.zhjd.server.modules.asphalt.service.impl;

import java.util.List;

import com.qzsoft.zhjd.server.modules.asphalt.service.CollectAsphaltMatchThresholdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;

import com.qzsoft.zhjd.server.modules.asphalt.entity.CollectAsphaltMatchThresholdEntity;
import com.qzsoft.zhjd.server.modules.asphalt.mapper.CollectAsphaltMatchThresholdMapper;

/**
 * @ClassName AsphaltMatchThresholdServiceImpl
 * @Description 上下限配置业务接口实现
 * @author linhuawei
 * @since 2022-02-09
 */
@Service
public class CollectAsphaltMatchThresholdServiceImpl implements CollectAsphaltMatchThresholdService {

    @Autowired
    private CollectAsphaltMatchThresholdMapper collectAsphaltMatchThresholdMapper;

    @Override
    public CollectAsphaltMatchThresholdEntity getByTypeAndName(String matchType, String matchName) {
        if(ObjectUtils.isEmpty(matchType) || ObjectUtils.isEmpty(matchName)) {
            return null;
        }
        QueryWrapper<CollectAsphaltMatchThresholdEntity> queryWrapper = new QueryWrapper<CollectAsphaltMatchThresholdEntity>();
        queryWrapper.eq("match_type", matchType);
        queryWrapper.eq("match_name", matchName);
        List<CollectAsphaltMatchThresholdEntity> list = collectAsphaltMatchThresholdMapper.selectList(queryWrapper);
        if (null == list || 1 != list.size()) {
            return null;
        }
        return list.get(0);
    }

}
